/**
 * Created by Fernando on 20/11/2014.
 */

var myUrl = Routing.generate('ventasMesAnterior');

var ajax = $.ajax({
    type: "post",
    url: myUrl,
    context: document.body
});

ajax.done(function(){
    //definir variable data del chart
    var jsonResponse = $.parseJSON(ajax.responseText);

    new Morris.Bar({
        // ID of the element in which to draw the chart.
        element: 'total_ventas',
        // Chart data records -- each entry in this array corresponds to a point on
        // the chart.
        data: [
            { tipo: 'Contado', total: jsonResponse['totales_mes'][0]['contado'] },
            { tipo: 'Tarjeta', total: jsonResponse['totales_mes'][0]['tarjeta'] }
        ],
        xkey: 'tipo',
        ykeys: ['total'],
        labels: ['Total $']
    });

    new Morris.Bar({
        // ID of the element in which to draw the chart.
        element: 'total_tipos',
        // Chart data records -- each entry in this array corresponds to a point on
        // the chart.
        data: jsonResponse['totales_tipo'],
        xkey: 'label',
        ykeys: ['value'],
        labels: ['Total $']
    });

});



